import ServiceBase from '../base';
import {ApplicationPageProxy, ApplicationProxy} from '../proxies/application-status-page-proxy';
import {MessagePageProxy} from '../proxies/message--page-proxy';
import * as proxy from '../proxy';

const ACCOUNT = '/accounts';

class ApplicationService extends ServiceBase {
    getApplication = (data) => {
        let promise = super.get({
            url: ACCOUNT + `/${data.accountId}/applications?pageNumber=${data.pageNumber}&pageSize=${data.pageSize}`,
        });
        return proxy.httpResultProxy(promise, MessagePageProxy);
    };
    sendApplication = (data) => {
        let promise = super.post({
            url: ACCOUNT + `/${data.accountId}/applications`,
            data: data.data,
        });
        return proxy.httpResultProxy(promise, ApplicationProxy);
    };
    updateApplication = (data) => {
        let promise = super.put({
            url: ACCOUNT + `/${data.accountId}/applications`,
            data: data.data,
        });
        return proxy.httpResultProxy(promise, ApplicationProxy);
    };
    getApplicationState = () => {
        let promise = super.get({
            url: `${ACCOUNT}/applications/me/state`,
        });
        return proxy.httpResultProxy(promise, ApplicationPageProxy);
    };
}

export {ApplicationService};
